from tensorflow.examples.tutorials.mnist import input_data
import numpy as np
import matplotlib.pyplot as plt


plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False

mnist = input_data.read_data_sets('MNIST_data', one_hot=True)
train_images = mnist.train.images
train_labels = mnist.train.labels

for i in range(50):
    img = np.reshape(train_images[i], (28, 28))
    label = np.argmax(train_labels[i, :])
    plt.matshow(img, cmap = plt.get_cmap('gray'))
    plt.title('Image:%d, Lable:%d' % (i + 1, label))
    plt.show()